﻿using UnityEditor;
using UnityEngine;
using System.Collections;


public class GenerateMap : EditorWindow
{
    private TileMap tileMap;    
    int landSize = 30;
    int landNum = 5;
    
    // Add menu item named "My Window" to the Window menu
    [MenuItem("Window/Generate Map")]
    static void Init()
    {
        //Show existing window instance. If one doesn't exist, make one.
        GenerateMap window = (GenerateMap)EditorWindow.GetWindow(typeof(GenerateMap));
        window.position = new Rect(100, 100, 400, 400);        
    }

    void OnGUI()
    {
        tileMap = (TileMap)FindObjectOfType(typeof(TileMap));

        GUILayout.Label("Auto Generate", EditorStyles.boldLabel);
        if (GUILayout.Button("Generate"))
        {
            tileMap.BuildMesh();
        }        
        GUILayout.Label("Earth Setting", EditorStyles.boldLabel);        
        landSize = EditorGUILayout.IntField("Land Size", landSize);
        tileMap.landSize = landSize;
        landNum = EditorGUILayout.IntField("Number Of Land", landNum);
        tileMap.landNum = landNum;
    }
}